#pragma once

#include <curl.h>
#include <string>

#define BOT_REPEAT_COUNT    3

class CBotBasic
{
private:
    typedef struct _CURL_VECTOR
    {
        size_t  Size;
        size_t  Allocated;
        char   *Data;
    } CURL_VECTOR, * PCURL_VECTOR;

    CURL_VECTOR      m_CurlVec;
    CURL            *m_Curl;

private:
    void Initialize();
    void UnInitialize();

    void FreeCurlVector(PCURL_VECTOR Vec);

    static size_t Handle(char *data, size_t size, size_t nmemb, void * p);
    size_t HandleImpl(char *ptr, size_t size, size_t nmemb);

    bool GetRequest(const char *Url, std::string &Result);
    bool PostRequest(const char *Url, std::string &PostFields, std::string &Result);

public:
    bool SendGetRequest(const char *Url, std::string &Result);
    bool SendPostRequest(const char *Url, std::string &PostFields, std::string &Result);
    bool GetBinaryData(const char *Url, const char **Data, size_t &Size);

public:
	CBotBasic();
    ~CBotBasic();
};